//% color="#4169E1" iconWidth=50 iconHeight=40
namespace DFRobot_VEML6075{

    //% block="Initialize VEML6075 UV sensor wait until successful" blockType="command" 
    
    export function DFRobot_VEML6075Init(parameter: any, block: any) {
       
        
        Generator.addImport("from DFRobot_VEML6075 import DFRobot_VEML6075");
        Generator.addImport("from pinpong.board import Board");
        Generator.addImport("import time");
        
        Generator.addCode("VEML6075 = DFRobot_VEML6075(0, 0x10)");
  
        Generator.addCode(`while VEML6075.begin() != True:
    print("VEML6075 begin faild")
    time.sleep(2)
print("VEML6075 begin succeed")
`);
       
        
    }
     //% block="Read VEML6075 [UV] Strength" blockType="reporter" 
     //% UV.shadow="dropdown"  UV.options="UV"
     export function DFRobot_VEML6075ReadyUV(parameter: any, block: any) { 
        let uv = parameter.UV.code

        Generator.addCode( [`VEML6075.get_uv${uv}()`,Generator.ORDER_UNARY_POSTFIX]);
   
   }

    //% block="Read VEML6075 UV Index" blockType="reporter"  
    export function DFRobot_VEML6075Ready(parameter: any, block: any) { 
        Generator.addCode( [`VEML6075.get_uvi(VEML6075.get_uva(),VEML6075.get_uvb())`,Generator.ORDER_UNARY_POSTFIX]);
   
   }

    //% block="Read VEML6075 Radiation Emitted Mw/cm2" blockType="reporter"  
    export function DFRobot_VEML6075ReadyME(parameter: any, block: any) { 

        Generator.addCode( [`VEML6075.uvi2mwpcm2(VEML6075.get_uvi(VEML6075.get_uva(),VEML6075.get_uvb()))`,Generator.ORDER_UNARY_POSTFIX]);
   
   }
   
    function replace(str :string) {
        return str.replace("\"", "").replace("\"", "");
    }
   
}